function format(json){
	var ret = [], o = {};
 
	function add(arr, data){
		var obj = {
			"id": data.id,
			"pid": data.pid,
			"name":data.name,
			"children": [],
            "type":data.type,
            "status":data.status,
            "url":data.url,
            "pname":data.pname
		};
		o[data.id] = obj;
		arr.push(obj);
	}
 
	json.forEach(x => {
		if(o[x.pid]){
			add(o[x.pid].children, x);
		}else{
			add(ret, x);
		}
	});
	return ret;
}
export default format;